

package com.hazelcast.internal.config.yaml;

import com.hazelcast.internal.yaml.YamlMapping;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import static com.hazelcast.internal.config.yaml.W3cDomUtil.asW3cNode;
import static com.hazelcast.internal.config.yaml.YamlOrderedMappingImpl.asOrderedMapping;

class NodeListMappingAdapter implements NodeList {
    private final YamlOrderedMapping yamlMapping;

    NodeListMappingAdapter(YamlMapping yamlMapping) {
        this.yamlMapping = asOrderedMapping(yamlMapping);
    }

    @Override
    public Node item(int index) {
        return asW3cNode(yamlMapping.child(index));
    }

    @Override
    public int getLength() {
        return yamlMapping.childCount();
    }
}
